home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_351 / pdc / libsrc.lzh / LibSrc / StringLib / strndup.c < prev    next >
C/C++ Source or Header  |  1990-04-07  |  720b  |  31 lines

  1. /*
  2.  * Libraries and headers for PDC release 3.3 (C) 1989 Lionel D. Hummel.
  3.  * PDC Software Distribution (C) 1989 Lionel Hummel and Paul Petersen.
  4.  * PDC I/O Library (C) 1987 by J.A. Lydiatt.
  5.  *
  6.  * This code is freely redistributable upon the conditions that this notice
  7.  * remains intact and that modified versions of this file not be included
  8.  * as part of the PDC Software Distribution without the express consent of
  9.  * the copyright holders.
  10.  */
  11.  
  12. /*
  13.  *    strndup.c
  14.  *
  15.  *    strndup() returns a duplicate string in a buffer n bytes long
  16.  */
  17.  
  18. char *strndup(string, n)
  19. char *string;
  20. int   n;
  21. {
  22.     char *retval;
  23.  
  24.     retval = malloc(n);
  25.  
  26.     if (retval != 0L)
  27.         strncpy(retval, string, n);
  28.  
  29.     return(retval);
  30. }
  31.